import 'package:flutter/material.dart';
import 'MenuPage.dart';
import 'MinePage.dart';
import 'MainPage.dart';

void main() => runApp(App());

class App extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      color: Color(0xff313131),
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  static final PAGE_SETTING = 0;
  static final PAGE_MAIN = 1;
  static final PAGE_MINE = 2;

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  List<Widget> viewList = [];
  PageController controller = PageController(
    initialPage: 1,
    keepPage: true
  );

  @override
  void initState() {
    super.initState();
    viewList.add(MenuPage(controller: this.controller));
    viewList.add(MainPage(controller: this.controller));
    viewList.add(MinePage(controller: this.controller));
  }

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      body: PageView.builder(
          itemCount: viewList.length,
          controller: this.controller,
          itemBuilder: (context, index) {
            return viewList[index];
          })
    );

  }
}
